#include "multimedia.h"


multimedia::multimedia(void)
{
	this->title = "no title";
	this->length = "0";
	this->company = "n/a";
	this->producer = "n/a";
	this->year = "0";
}

multimedia::multimedia(string tit,
		string pro,
		string com,
		string len,
		string y)
{
	this->title = tit;
	this->length = len;
	this->company = com;
	this->producer = pro;
	this->year = y;
}

	ostream& operator <<(ostream& stream, multimedia& item){
		stream << item.title;
		stream << ", " << item.producer;
		stream << ", " << item.company;
		stream << ", " << item.length;
		stream << ", " << item.year;
		return stream;
	}
	istream& operator >>(istream& stream, multimedia& item){
		getline(stream, item.title, ',');
		stream >> skipws;
		getline(stream, item.producer, ',');
		stream >> skipws;
		getline(stream, item.company, ',');
		stream >> skipws;
		getline(stream, item.length, ',');
		stream >> skipws;
		getline(stream, item.year);
		return stream;
	}

	
	int operator ==(multimedia& lop, multimedia& hop){
		if (lop.title == hop.title){
			if (lop.company == hop.company){
				if (lop.producer == hop.producer){
					if (lop.length == hop.length){
						if (lop.year == hop.year){
							return true;
						}
					}
				}
			}
		}
		return false;
	}

	int operator <(multimedia& lop, multimedia& hop){
		bool b = lop.title.compare(hop.title);
		if (b == 0){
			return false;
		}
		else if (b > 0){
			return false;
		}
		else
		{
			return true;
		}
	}
	multimedia::~multimedia(void)
	{
	}

	int multimedia::isAlike(string s){
		int i = (title.find(s) != std::string::npos);
		i += (producer.find(s) != std::string::npos);
		i += (company.find(s) != std::string::npos);
		i += (length.find(s) != std::string::npos);
		i += (year.find(s) != std::string::npos);
		return i;
	}
